package com.yihu.yihuds.action;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.yihu.article.beans.Article;
import com.yihu.article.beans.ArticleContent;
import com.yihu.article.beans.ArticleQuery;
import com.yihu.cms.action.BaseController;
import com.yihu.cms.bean.comment.Comment;
import com.yihu.cms.service.ArticleService;
import com.yihu.cms.util.CommonUtils;
import com.yihu.web.bean.vo.CommentQuery;
import com.yihu.yihuds.service.CommentService;

@Controller
public class CommentController extends BaseController{
	private final Logger logger = LoggerFactory.getLogger(CommentController.class); 
	private CommentService service = new CommentService();
	
	@RequestMapping(value = "/comment", method = RequestMethod.POST)
	public @ResponseBody Object add(@RequestBody Comment comment) {
		return service.add(comment);
	}
	
	@RequestMapping(value = "/comment/audit", method = RequestMethod.PUT)
	public @ResponseBody Object audit(@RequestBody Comment comment) {
		return service.updateComment(comment);
	}
	
	
	@RequestMapping(value = "/comment/{id}", method = RequestMethod.DELETE)
	public @ResponseBody Object deleteComment(@PathVariable("id") String id) {
		return service.delete(id);
	}
	@RequestMapping(value = "/comment/{id}", method = RequestMethod.GET)
	public @ResponseBody Object getComment(@PathVariable("id") String id) {
		return service.get(id);
	}
	
	@RequestMapping(value = "/comment/list" , method = RequestMethod.GET)
	// , method = RequestMethod.PATCH
	public @ResponseBody Object getComments(CommentQuery query) {
		
		return service.getComments(query);
	}

	

}
